package com.qk.management.service.validator;

import com.qk.common.constants.AvatarMessageConstants;
import org.springframework.web.multipart.MultipartFile;
import java.util.Set;

public class FileTypeValidator extends FileValidationHandler {
    private final Set<String> allowedTypes;
    
    public FileTypeValidator(Set<String> allowedTypes) {
        this.allowedTypes = allowedTypes;
    }
    
    @Override
    protected void handle(MultipartFile file) throws ValidationException {
        String contentType = file.getContentType();
        if (contentType == null || !allowedTypes.contains(contentType)) {
            throw new ValidationException(AvatarMessageConstants.UNSUPPORTED_FILE_TYPE + ": " + contentType);
        }
    }
}